<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>

<script type="text/javascript">

//篮球基类
var Basketball = function () {
	this.intro = '篮球流行于美国';
}

Basketball.prototype = {

	getMember : function() {
		console.error('每个队伍需要5名队员');
	},
	getBallSize : function() {
		console.error('篮球很大');
	}
};

//足球基类
var Football = function() {
	this.intro = '足球在世界范围内很流行';
}

Football.prototype = {

	getMember : function() {
		console.error('每个队伍需要11名队员');
	},
	getBallSize : function() {
		console.error('足球很大');
	}
}

//网球基类
var Tennis = function() {
	this.intro = '每年有很多系列赛';
}

Tennis.prototype = {

	getMember : function() {
		console.error('每个队伍需要1名队员');
	},
	getBallSize : function() {
		console.error('网球很小');
	}
}

var SportsFactory = function(name) {
	switch(name) {
		case 'NBA':
			return new Basketball();
		case 'wordCup':
			return new Football();
		case 'FrenchOpen':
			return new Tennis();
	}
}

var football = SportsFactory('wordCup');
console.error(football);
console.error(football.intro);
football.getMember();


</script>

</body>
</html>